﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace MMK.PaketTracker.Server.Web.Application
{
	public partial class ShwLog : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			DateTime dt = System.DateTime.Now;

			if (Request.QueryString.Count > 0 && Request.QueryString[0] != null)
			{
				try
				{
					dt = DateTime.Parse(Request.QueryString[0]);
				}
				catch 
				{
					Response.Write("Ungültiges Datum");
					Response.End();
				}
			}

			string logFile = Server.MapPath("Webservices/Log/" + System.DateTime.Now.ToString("yyyyMMdd") + ".log");

			if (File.Exists(logFile))
			{
				using (StreamReader reader = new StreamReader(logFile))
				{
					string fileContent = reader.ReadToEnd();

					fileContent = fileContent.Replace("\r\n", "<br>");
					lblLog.Text = fileContent;
				}
			}
			else
			{
				Response.Write("Kein Log-File gefunden");
				Response.End();
			}

		}
	}
}